Xbasic

SQL::ConnectionCreateTable Method

Syntax

Result_Flag as L = CreateTable(TableInfo as SQL::TableInfo)

Arguments

TableInfoSQL::TableInfo

A SQL::TableInfo object.

Returns

Result_FlagLogical

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

Description

Create a table in the currently connected database using the TableInfo specification.

Discussion

The CreateTable() method creates a table in the currently connected database using the TableDef specification. SQL::Connection::CreateTable (which calls GenerateCreateTableSyntax) can recognize and map geography types. This can be a fairly complicated process as described in Database-specific Geography Tasks V11. Oracle, for example, requires that a spatial index be created to use comparison functions. Some databases require separate code to add geography/geometry columns.

Example

Note that a new field must have a name, length, and an Intermediate type.

dim ti as SQL::TableInfo
dim conn as SQL::Connection
dim dt as SQL::DataTypeInfo
if .not. conn.open("{A5API=Access,FileName='C:\Program Files\A5V8\MDBFiles\Alphasports.mdb', UserName='Admin'}") then
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
dt.Name = "Name"
dt.Length = 50
dt.IntermediateType = "Character"
ti.name = "NewTable"
if ti.AddColumn(dt) = 0 then
    end
end if
if .not. conn.CreateTable(ti) then
    ui_msg_box("Error", conn.CallResult.text)
end if
conn.close()

See Also